<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>后台管理模板</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="stylesheet" href="../../layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="../../css/global.css" media="all">
		<link rel="stylesheet" type="text/css" href="http://www.jq22.com/jquery/font-awesome.4.6.0.css">
		<link rel="stylesheet" href="../../datatables/media/css/jquery.dataTables.css">
		<link rel="stylesheet" href="../../datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css">
	</head>
	<body>
		<div class="layui-layout layui-layout-admin" style="border-bottom: solid 5px #1aa094;">
			<!--头部导航-->
			<div class="layui-header header header-demo" ></div>
			<!--左侧导航-->
			<div class="layui-side layui-bg-black" id="admin-side">
			</div>
			<!--右侧具体内容-->
			<div class="layui-body" style="bottom: 0;border-left: solid 2px #1AA094;padding:20px" id="admin-body">
				<div class="title">投诉列表</div>
				<hr />
				<div class="select" >
					<select name="complainselect" lay-verify="" id="complainSequence">
						<option value="0">状态</option>
						<option value="1">未处理</option>
						<option value="2">已处理</option>
					</select>
				</div>
				<div class="layui-form">
					<table class="layui-table" id="complainTable">
						<thead>
							<tr>
								<th style="width: 200px">投诉时间</th>
								<th style="width: 200px">被投诉对象</th>
								<th style="width: 200px">投诉发起方</th>
								<th>内容</th>
								<th style="width: 200px">状态</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<td>2017-6-30</td>
								<td><img src="../../images/1.jpg"><span>adj</span></td>
								<td><img src="../../images/0.jpg"><span>lzy</span></td>
								<td>没送货到家</td>
								<td>未处理</td>
								<td><div class="layui-btn  layui-btn-small complain_detail">详情</div></td>
							</tr>
							<tr>
								<td>2017-6-30</td>
								<td><img src="../../images/xiaosong.jpg"><span>lzy</span></td>
								<td><img src="../../images/0.jpg"><span>dssd</span></td>
								<td>没送货到家</td>
								<td>未处理</td>
								<td><div class="layui-btn  layui-btn-small complain_detail">详情</div></td>
							</tr>
							<tr>
								<td>2017-6-30</td>
								<td><img src="../../images/6.jpg"><span>wqds</span></td>
								<td><img src="../../images/0.jpg"><span>lzy</span></td>
								<td>没送货到家</td>
								<td>已处理</td>
								<td><div class="layui-btn  layui-btn-small user_detail">详情</div></td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
				<!--底部导航-->
				<div class="layui-footer footer footer-demo" id="admin-footer"></div>
				<!--JS模块-->
				<script type="text/javascript" src="../../layui/layui.js"></script>
				<script src="../../js/jquery-1.12.3.min.js"></script>
				<script src="../../js/index.js"></script>
				<script type="text/javascript" src="../../js/jquery.cookie.js"></script>
				<!-- DataTables JavaScript -->
				<script src="../../datatables/media/js/jquery.dataTables.min.js"></script>
				<script>
				var data = {
					"count": 26936,
					"complains": [{
						"id": 159753,
						"complainTime": 7533354677777,
						"beComplainUserNickname": "小白兔",
						"beComplainUserHeadPortraitUrl": "../../images/am.jpg",
						"nickname": "大灰狼",
						"headPortraitUrl": "../../images/dx.jpg",
						"complainContent": "没送货到家",
						"complainState": 0, //0未完成 1完成
						"username": "15967179999",
						// "beComplainUserId": 75055,
						// "complainUserId": 76216,
					}, {
						"id": 11111,
						"complainTime": 75333,
						"beComplainUserNickname": "小白兔",
						"beComplainUserHeadPortraitUrl": "../../images/mm.jpg",
						"nickname": "大灰狼",
						"headPortraitUrl": "../../images/1.jpg",
						"complainContent": "没送货到家",
						"complainState": 1, //0未完成 1完成
						"username": "15967179922",
					}, {
						"id": 222222,
						"complainTime": 75333,
						"beComplainUserNickname": "zylin",
						"beComplainUserHeadPortraitUrl": "../../images/fems.jpg",
						"nickname": "福尔摩斯",
						"headPortraitUrl": "../../images/0.jpg",
						"complainContent": "没送货到家",
						"complainState": 0, //0未完成 1完成
						"username": "15967179944",
					}]
				}
				$(function() {
					$("#complain").addClass('layui-this'); //对应订单管理的背景色
					$('#complainTable').DataTable({
						responsive: true,
						ordering: false,
						searching: true,
						"bLengthChange": false,
						"bRetrieve": true,
						"bFilter": true, //过滤功能
					});
					//alert(1223)
					adminCookie()
					complainSelectChange(0)
				})
				
				$("#complainSequence").bind("change", function() {
					complainSelectChange($(this).val())
				})

				function complainSelectChange(v) {
					$.ajax({
						type: "get",
						url: "/randomdelivery/AdminController/complain",
						data:{sequence:v},
						async: true,
						dataType: "json",
						contentType: "application/json",
						success: function(data) {
							JSON.stringify(data)
							complaindata(data);
						},
						Error: function() {
							alert("服务器出错");
						}
					})
				}

				function complaindata(data) {
				$('#complainTable').dataTable().fnClearTable(); //清除表格内
				$.each(data.complains, function(index, item) {
					//alert(JSON.stringify(item))
						var state
						var complainTime = new Date(item.complainTime).Format("yyyy-MM-dd hh:mm:ss")
						if (parseInt(item.complainState) == 0) {
							state = "未完成";
						} else {
							state = "已完成";
						}
						$('#complainTable').dataTable().fnAddData([
							complainTime,
							'<img src=' + item.beComplainUserHeadPortraitUrl + '><span>' + item.beComplainUserNickname + '</span>',
							'<img src=' + item.headPortraitUrl + '><span>' + item.nickname + '</span>',
							item.complainContent,
							state,
							'<a href="complaindetail.html?id=' + item.id + '"><div class="layui-btn  layui-btn-small user_detail">详情</div></a>'
						]);
						if (item.complainState == 1) {
							//$("table#complainTable").find('tr:eq('+(parseInt(index)+1)+')').children('nth-children(5)').css('color', 'blue');
							$("table#complainTable").find('tr:eq('+(index+1)+')').children('td:nth-child(5)').css('color', 'blue');
							//alert((element).children("nth-children(5)").attr("class"))
						}
					})
			}

					</script>
					
				</div>
			</body>
		</html>